<template>
	<view><web-view :src="pageUrl" @message="handleMessage"></web-view></view>
</template>

<script>
import { mapState, mapMutations } from 'vuex';
export default {
	computed: mapState(['URL']),
	data() {
		return {
			pageUrl: 'http://jjc.tust.edu.cn/api/login?authId=123'
		};
	},
	methods: {
		...mapMutations(['LOGIN', 'TO_UPDATE', 'GET_USER_INFO']),
		handleMessage(evt) {
			this.LOGIN(evt.detail.data[0]['token']);
			uni.setStorage({
				key: 'USER_INFO',
				data: {
					userHeadimg:'',
					userNickname:''
				},
				success: res => {
					console.log(111);
				}
			});
			this.TO_UPDATE(true);
			console.log('接收到的消息：' + JSON.stringify(evt.detail.data[0]['token']));
		}
	},
	onShow() {
		//清除旧token 用统一认证页面 获取新 token
		uni.request({
			url: this.URL + 'logout',
			header: {
				token: this.TOKEN
			},
			method: 'POST',
			success: res => {
				console.log("qingchu");
			}
		});
	}
};
</script>

<style></style>
